/*
 * radio.cc
 *
 * Radio tests
 *
 *  Created on: Oct 16, 2014
 *      Author: andy
 */

#include <catch.hpp>
#include "../src/Radio.h"

TEST_CASE( "Radio data is valid", "[radio]") {
	Radio r;

	// Ensure radial is in the correct range
	REQUIRE(r.getRadial() >= 0);
	REQUIRE(r.getRadial() < 360);

	// Ensure identifier is all uppercase letters
	for(int i = 0; i < 3; ++i) {
		REQUIRE(r.getIdent()[0] >= 'A');
		REQUIRE(r.getIdent()[0] <= 'Z');
	}
}

TEST_CASE( "Same frequency gives same data", "[radio]" ) {
	Radio r;

	r.setFrequency(1);

	// Save the values reported by the radio for freq. 1
	int r1 = r.getRadial();
	bool v1 = r.isValid();
	const char* i1 = r.getIdent();

	// Switch freq., read some data
	r.setFrequency(2);
	r.getRadial(); r.isValid(); r.getIdent();

	// Switch back to freq 1, make sure we still get the original values.
	r.setFrequency(1);
	REQUIRE(r1 == r.getRadial());
	REQUIRE(v1 == r.isValid());
	for(int i = 0; i < 3; ++i) {
		REQUIRE(i1[i] == r.getIdent()[i]);
	}
}
